import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

public class FunctionalDemo {
    
    private static Predicate<String> predicate;
    
    public static void main(String[] args) {
        //function apply
        applyTest((request)->r2r(request),"request");
        //consumer accept
        consumeTest((request)-> System.out.println(request),"request");
    
        predicateTest((request)->request.equals("ok"),"ok");
    
        supplierTest(()->"response");
    }
    
    public static void supplierTest(Supplier<String> supplier){
        supplier.get();
    }
    
    public static void predicateTest(Predicate<String> predicate,String param){
        predicate.test(param);
    }
    
    public static void applyTest(Function<String,String> apply,String param){
        var response = apply.apply(param);
        System.out.println(response);
    }
    
    public static void  consumeTest(Consumer<String> consumer,String param){
        consumer.accept(param);
    }
    
    public static String r2r(String request){
        return "response";
    }
}
